import lookup from "./lookup.js";
import parseArray from "./parseArray.js";

export default function renderTemplate(tokens, data){
    var res = "";
    for(let i=0; i<tokens.length; i++){
        let token = tokens[i];
        if(token[0] === "text"){
            res += token[1];
        }else if(token[0] === "name"){
            res += lookup(data,token[1]);
        }else if(token[0]=== "#"){
            res += parseArray(token,data)
        }
    }
    return res;
}